{% extends 'layout/main.html' %}
{% block content_header %}
    <h1>
      栏目管理
    </h1>
    <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li><a href="#">栏目管理</a></li>
    <li class="active">栏目列表</li>
    </ol>
{% endblock %}


{% block content %}
    <div class="box">
        <div class="box-header with-border">
            <a class="btn btn-success" href="{{ url_for('category.create') }}">添加栏目</a>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
            <table class="table table-bordered table-striped">
              <thead>
                <tr>
                  <th style="width: 10px">#</th>
                  <th>栏目名称</th>
                  <th width="150">创建时间</th>
                  <th width="150">更新时间</th>
                  <th style="width: 40px">操作</th>
                </tr>
              </thead>
              <tbody>
                {% if model %}
                {% for item in model %}
                <tr>
                  <td>{{ item.id }}</td>
                  <td><span style="padding-left: {{ item.level*2 }}0px;">{% if item.level %}├─{% endif %}{{ item.title }}</span></td>
                  <td>{{ item.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</td>
                  <td>{{ item.updated_at.strftime('%Y-%m-%d %H:%M:%S') }}</td>
                  <td style="width:100px">
                    <a href=""><span class="glyphicon glyphicon-user"></span></a>
                    <a href="{{ url_for('category.update', id=item.id) }}"><span class="glyphicon glyphicon-pencil"></span></a>
                    <a href="{{ url_for('category.delete', id=item.id) }}" onclick="return confirm('真的要删除吗')"><span class="glyphicon glyphicon-trash"></span></a>
                  </td>
                </tr>
                {% endfor %}
                {% endif %}
              </tbody>
            </table>
        </div>
    </div>
{% endblock %}
